// ActionScript file


import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.rpc.events.ResultEvent;
import mx.managers.PopUpManager;



private function onListar( event:ResultEvent ):void{
	dg.dataProvider = event.result as Object;
	bteditar.enabled = true;
	dg.enabled = true;
	btexcluir.enabled = true;
	btnovo.enabled = true;
	bordercontent.enabled = false;
	btcancelar.enabled = false;
	btsalvar.enabled = false;
	dg.selectedIndex = 0;
}

private function salvar():void{
	var a:ArrayCollection = new ArrayCollection();
	
	a.addItem( { 
		
		
	} );
	Remote.salvar(a);
}

public function excluir():void{
	Alert.yesLabel='Sim';
	Alert.noLabel='Não';
	Alert.show('Deseja realmente excluir esse registro?','ATENÇÃO',Alert.YES|Alert.NO, null, excluirResult);
}public function excluirResult(e:CloseEvent):void{
	if(e.detail == Alert.YES){
		Remote.excluir( pn_id.text );
	}
}


private function editar():void{
	dg.enabled = false;
	bteditar.enabled = false;
	btexcluir.enabled = false;
	btnovo.enabled = false;
	bordercontent.enabled = true;
	btcancelar.enabled = true;
	btsalvar.enabled = true;
}

private function cancelar():void{
	bteditar.enabled = true;
	dg.enabled = true;
	btexcluir.enabled = true;
	btnovo.enabled = true;
	bordercontent.enabled = false;
	btcancelar.enabled = false;
	btsalvar.enabled = false;
}	

private function novo():void{
	bordercontent.enabled = true;
	dg.enabled	=	false;
	btsalvar.enabled = true;
	btcancelar.enabled = true;
	resets();
}


private function resets():void{	
	pn_id.text	= 	null;
}	


private function atualizarGrid():void{
	//	selectComboBox( pn_carteira , dg.selectedItem.id , 'id' );
}







